/*
 * @Author: your name
 * @Date: 2021-06-24 10:13:51
 * @LastEditTime: 2021-06-26 00:11:14
 * @LastEditors: Please set LastEditors
 * @Description: In User Settings Edit
 * @FilePath: \totiao\src\api\articleApi.js
 */
import request from '../utils/request'

// 获取文章详情
export const getArticleInfoApi = function (id) {
  return request.get('/v1_0/articles/' + id)
}

// 关注作者的api接口
export const followUserApi = function (target) {
  return request.post('/v1_0/user/followings', { target })
}

// 取消关注作者的api接口
// id 是文章作者的id
export const onfollowUserApi = function (id) {
  return request.delete('/v1_0/user/followings/' + id)
}

// 点赞文章
export const LikeitApi = function (target) {
  return request.post('/v1_0/article/likings', { target })
}

// 取消点赞文章
export const onLikeitApi = function (id) {
  return request.delete('/v1_0/article/likings/' + id)
}

// 文章的评论列表
export const getCmtListApi = function (source, offset) {
  return request.get('/v1_0/comments', {
    params: {
      type: 'a',
      // 文章的id
      source,
      // 偏移量,用来实现分页
      offset
    }
  })
}
// 点赞评论
export const liking = function (target) {
  return request.post('/v1_0/comment/likings', { target })
}
// 评论取消点赞
export const onliking = function (id) {
  return request.delete('/v1_0/comment/likings/' + id)
}

// 发布评论的api
// target 是文章的 Id
// content 评论的内容
export const publishCommentApi = function (target, content) {
  return request.post('/v1_0/comments', {
    target,
    content
  })
}
